﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace JohnnySins
{
    public static class CurrentUsers
    {
        static List<string> users = new List<string>();
        static List<string> wrongUsers = new List<string>();
        static object _locker = new object();

        public static bool CanLogin(string userName)
        {
            lock (_locker)
            {
                if (users.Contains(userName))
                {
                    if (!wrongUsers.Contains(userName))
                    {
                        wrongUsers.Add(userName);
                    }
                    return false;
                }
                else
                {
                    users.Add(userName);
                    return true;
                }
            }
        }

        public static bool IsWrong(string userName)
        {
            lock (_locker)
            {
                return wrongUsers.Contains(userName);
            }
        }

        public static void Remove(string userName)
        {
            lock (_locker)
            {
                if (users.Contains(userName))
                {
                    users.Remove(userName);
                }

                if (wrongUsers.Contains(userName))
                {
                    wrongUsers.Remove(userName);
                }
            }
        }
    }
}